home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 114 / macaddict114.cdr / Software / Utilities / macam.0.8.4.dmg / macam sources / utilities / yuv2rgb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-25  |  5.7 KB  |  128 lines

  1. /*
  2.     macam - webcam app and QuickTime driver component
  3.     Copyright (C) 2002 Matthias Krauss (macam@matthias-krauss.de)
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  $Id: yuv2rgb.c,v 1.2 2002/10/25 10:00:37 mattik Exp $
  19. */
  20.  
  21. #include "yuv2rgb.h"
  22. #include <stdio.h>
  23.  
  24. //Lazy preprocessor generation of blitter code. For documentation, see "yuv2rgbPhilips.c".
  25.  
  26. #undef YUV2RGB_CPIA420STYLE
  27. #undef YUV2RGB_FLIP
  28. #undef YUV2RGB_ALPHA
  29. void _philips2rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  30. #include "yuv2rgbPhilips.c"
  31. }
  32. void _cpia4202rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  33. #include "yuv2rgbCPIA420.c"
  34. }
  35. void _cpia4222rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  36. #include "yuv2rgbCPIA422.c"
  37. }
  38. void _ov4202rgb888      (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  39. #include "yuv2rgbOV420.c"
  40. }
  41.     
  42. #undef YUV2RGB_FLIP
  43. #define YUV2RGB_ALPHA
  44. void _philips2argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  45. #include "yuv2rgbPhilips.c"
  46. }
  47. void _cpia4202argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  48. #include "yuv2rgbCPIA420.c"
  49. }
  50. void _cpia4222argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  51. #include "yuv2rgbCPIA422.c"
  52. }
  53. void _ov4202argb8888    (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  54. #include "yuv2rgbOV420.c"
  55. }
  56.     
  57. #define YUV2RGB_FLIP
  58. #undef YUV2RGB_ALPHA
  59. void _philips2rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  60. #include "yuv2rgbPhilips.c"
  61. }
  62. void _cpia4202rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  63. #include "yuv2rgbCPIA420.c"
  64. }
  65. void _cpia4222rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  66. #include "yuv2rgbCPIA422.c"
  67. }
  68.  
  69. void _ov4202rgb888flip  (int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  70. #include "yuv2rgbOV420.c"
  71. }
  72.     
  73. #define YUV2RGB_FLIP
  74. #define YUV2RGB_ALPHA
  75. void _philips2argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  76. #include "yuv2rgbPhilips.c"
  77. }
  78. void _cpia4202argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  79. #include "yuv2rgbCPIA420.c"
  80. }
  81. void _cpia4222argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  82. #include "yuv2rgbCPIA422.c"
  83. }
  84.  
  85. void _ov4202argb8888flip(int width, int height, unsigned char *src, unsigned char *dst, long srcRowExtra, long dstRowExtra) {
  86. #include "yuv2rgbOV420.c"
  87. }
  88.  
  89. #undef YUV2RGB_FLIP
  90. #undef YUV2RGB_ALPHA
  91.  
  92. void yuv2rgb(int width,
  93.              int height,
  94.              YUVStyle style,
  95.              unsigned char *src,
  96.              unsigned char *dst,
  97.              short bpp,
  98.              long srcRowExtra,
  99.              long dstRowExtra,
  100.              bool flip) {
  101.  
  102.     long decide=4*((unsigned long)style)+((bpp==4)?2:0)+((flip)?1:0);
  103.     //Bit 0=flip, bit 1=alpha, bit 2...=cpiaStyle
  104.     switch (decide) {
  105.         case  0: _philips2rgb888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  106.         case  1: _philips2rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  107.         case  2: _philips2argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  108.         case  3: _philips2argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  109.         case  4: _cpia4202rgb888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  110.         case  5: _cpia4202rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  111.         case  6: _cpia4202argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  112.         case  7: _cpia4202argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  113.         case  8: _cpia4222rgb888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  114.         case  9: _cpia4222rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  115.         case 10: _cpia4222argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  116.         case 11: _cpia4222argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  117.         case 12: _ov4202rgb888            (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  118.         case 13: _ov4202rgb888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  119.         case 14: _ov4202argb8888        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  120.         case 15: _ov4202argb8888flip        (width,height,src,dst,srcRowExtra,dstRowExtra); break;
  121.         default:
  122. #ifdef _VERBOSE_
  123.         printf("yuv2rgb: unknown conversion\n");
  124. #endif
  125.             break;
  126.     }
  127. }
  128.